package day12.edu;

// Created: 12/09/2025, ChangJiang Ru
public class PrintNumber2 {
    public static void main(String[] args) {
        PrintNumber3 j = new PrintNumber3("My Thread 1");
        j.setName("Myself Thread");
        j.setPriority(Thread.MIN_PRIORITY);

        j.start();

        Thread.currentThread().setName("Main Thread");
        Thread.currentThread().setPriority(Thread.MAX_PRIORITY);

        for (int i = 0; i <= 100; i++) {
            if(i % 2 == 0)
                System.out.println(Thread.currentThread().getName() + " " + Thread.currentThread().getPriority() +
                        "======>" + i);
            /*
            if(i % 20 == 0)
            {
                try {
                    j.join();
                }catch(InterruptedException e)
                {
                    e.printStackTrace();
                }
            }

             */
        }

//        System.out.println("My Thread 1 if alive ? " + j.isAlive());

//        Thread.sleep(1000);
    }
}

class PrintNumber3 extends Thread
{
    @Override
    public void run()
    {
        for (int i = 0; i <= 100; i++) {
            /*
            try
            {
                Thread.sleep(1000);
            }catch(InterruptedException e)
            {
                e.printStackTrace();
            }

             */
            if(i % 2 == 0)
                System.out.println(Thread.currentThread().getName() + "----->" + i);

            /*
            if(i % 20 == 0)
                Thread.yield();

             */
        }
    }

    public PrintNumber3()
    {

    }
    public PrintNumber3(String name)
    {
        super(name);
    }
}